<?php
/**
 * CreateTime: 2023/6/1 14:34
 */

namespace App\Models\MeLawCase;

use App\Consts\TableConsts\TableConsts;
use App\Models\BaseModelV2;
use App\Scopes\MediationStaffScope;

class MeLawCaseLawLetterModel extends BaseModelV2
{
    protected $table = TableConsts::LAW_CASE_LAW_LETTER;

    protected $primaryKey = 'law_case_law_letter_id';

    protected $fillable = [
        'law_case_law_letter_id',
        'law_case_id',
        'short_link_id',
        'pdf_water_path',
        'pdf_path',
        'pdf_path_hash',
        'file_image_dir',
        'created_time',
        'read_time',
        'recently_read_time',
        'progress',
        'browser',
        'duration',
        'read_count'
    ];

    public function getByLawCaseId($lawCaseId)
    {
        return $this->where('law_case_id',$lawCaseId)->orderBy('law_case_law_letter_id','DESC')->first();
    }

    public function getByLawCaseIdNotCom($lawCaseId)
    {
        return $this->withoutGlobalScope(MediationStaffScope::class)->where('law_case_id',$lawCaseId)->orderBy('law_case_law_letter_id','DESC')->first();
    }
}